package com.jason.bookworm.controller;

import com.jason.bookworm.dao.pojo.Book;
import com.jason.bookworm.response.Result;
import com.jason.bookworm.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/search")
public class SearchController {

    @Autowired
    private SearchService searchService;

    //根据书名搜索
    @GetMapping("/byBookName/{bookName}")
    public Result<List<Book>> searchByBookName(@PathVariable String bookName) {
        return searchService.searchByBookName(bookName);
    }

    //根据作者搜索
    @GetMapping("/byAuthor/{author}")
    public Result<List<Book>> searchByAuthor(@PathVariable String author) {
        return searchService.searchByAuthor(author);
    }

    //根据出版社搜索
    @GetMapping("/byPublish/{publish}")
    public Result<List<Book>> searchByPublish(@PathVariable String publish){
        return searchService.searchByPublish(publish);
    }
}
